﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Diagnostics;

namespace IA2MazeSolver
{
    public class MazeData
    {
        public int[][] Data;
        public int Width;
        public int Height;

        public MazeData(int[][] data, int w, int h)
        {
            this.Width = w;
            this.Height = h;

            this.Data = new int[h][];

            for (int i = 0; i < this.Height; i++)
            {
                this.Data[i] = new int[w];
                for (int j = 0; j < this.Width; j++)
                {
                    this.Data[i][j] = data[i][j];
                }
            }
        }

        public void AddValue(Point p, byte value)
        {
            if (p.X >= 0 && p.X < this.Width && p.Y >= 0 && p.Y < this.Height)
            {
                this.Data[p.Y][p.X] = this.Data[p.Y][p.X] + value;
            }
        }

        public void SetValue(Point p, int value)
        {
            if (p.X >= 0 && p.X < this.Width && p.Y >= 0 && p.X < this.Height)
            {
                this.Data[p.Y][p.X] = value;
            }
        }

        public int GetValue(Point p)
        {
            if (p.X < 0 || p.X >= this.Width || p.Y < 0 || p.Y >= this.Height)
            {
                return -1;
            }
            else
            {
                return this.Data[p.Y][p.X];
            }
        }

        public void ToDebug()
        {
            Debug.WriteLine("-----------");
            for (int i = 0; i < this.Height; i++)
            {
                Debug.Write("|");
                for (int j = 0; j < this.Width; j++)
                {
                    Debug.Write(this.Data[i][j]);
                    Debug.Write("|");
                }
                Debug.Write(Environment.NewLine);
            }
        }
    }
}
